#include "giza.h"

void usage()
{
	fprintf( stderr, "usage: 1-m giza-file\n" );
}

bool start( char *giza_fn )
{
	CGiza giza;
	if( giza.Open( giza_fn ) == false )	{
		fprintf( stderr, "Giza file %s fail\n", giza_fn );
		return false;
	}

	///////////
	int num_sent = 0;
	int num_align = 0;
	int num_cross = 0;
	int m[12];
	for( int i=0; i<=10; i++ )	m[i] = 0;

	while(1)	{
		if( giza.ReadSent() == false )	{
			break;
		}
		num_sent++;

		CUStringList l;
		for( int i=0; i< giza.align.align_list.GetSize(); i++ )	{
			CUString str = giza.align.align_list.GetAt(i);
			CUStringList idlist;
			idlist.TokenizeByChar( str, " ", false );

			if( idlist.GetSize() <= 4 )	
				m[idlist.GetSize()]++;
			else
				m[5]++;

		}
	}

	fprintf( stdout, "num_sent\t%d\n", num_sent );
	for( int i=0; i<=10; i++ )	{
		fprintf( stdout, "[%d]\t%d\n", i, m[i] );
	}

	return true;
}

int main( int argc, char *argv[] )
{
	if( argc != 2 )	{
		usage();
		return 1;
	}

	if( start( argv[1] ) == false )	{
		return 1;
	}

	return 0;
}
